package routers

import (
	"goadmin/controllers/api"
	"goadmin/middlewares"

	"github.com/gin-gonic/gin"
)

func ApiRoutersInit(r *gin.Engine) {
	//不需要token的
	apiRouters := r.Group("/api")
	{
		apiRouters.GET("/", api.UserController{}.Index)
		apiRouters.POST("/mini_login", api.UserController{}.WxLogin)
	}
	//需要token的路由
	apiUserTokenRouters := r.Group("/api", middlewares.InitUserAuthMiddleware, middlewares.PaginationMiddleware())
	{
		apiUserTokenRouters.POST("/user/update_phone", api.UserController{}.UpdatePhone)
		apiUserTokenRouters.GET("/user/detail", api.UserController{}.UserDetail)
		apiUserTokenRouters.POST("/send_message", api.UserController{}.SendMessage)
		apiUserTokenRouters.GET("/product", api.ProductController{}.List)
		apiUserTokenRouters.GET("/products/:id", api.ProductController{}.Show)
		apiUserTokenRouters.GET("/order", api.OrderController{}.OrderList)
		apiUserTokenRouters.GET("/order/:id", api.OrderController{}.OrderShow)
		apiUserTokenRouters.POST("/order", api.OrderController{}.AddOrder)
	}

}
